package com.ccjq.shosestore.core.dbmanager;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * describe: 配置文件读取器
 *
 * @author xugang
 * @date 2018/11/1 8:28
 */
public class DbConfigReader {

	private Properties properties;

	public DbConfigReader() {
		this.read();
	}

	/**
	 * 读取配置文件
	 */
	private void read() {
		properties = new Properties();
		InputStream is = DbConfigReader.class.getResourceAsStream("/dbConfig.properties");
		try {
			properties.load(is);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	/**
	 * 根据键获取值
	 *
	 * @param key 参数名
	 * @return 参数值
	 */
	public String getValue(String key) {
		return properties.getProperty(key);
	}

	/**
	 * 测试
	 *
	 * @param args
	 */
	/*
	 * public static void main(String[] args) { DbConfigReader dbConfigReader = new
	 * DbConfigReader(); System.out.println(dbConfigReader.getValue("db.driver")); }
	 */
}
